<?php

	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
	{
		die ('Please do not load this page directly. Thanks!');
	}
	
	if (post_password_required())
	{
		echo '<p class="nocomments">' . __('This post is password protected. Enter the password to view comments.', 'fazio') . '</p>';
		return;
	}

?>
				<div id="comments">
					<?php if ( have_comments() ) : ?>
						<?php if ( ! empty($comments_by_type['comment']) ) : ?>
							<h2><?php comments_number(__('No Comments - Send one now!'), __('1 Comment until now'), sprintf(__('%d comments until now', 'fazio'), get_comments_number())); ?></h2>
                            
							<ul class="comments_list">
								<?php wp_list_comments('type=comment&callback=fazio_comments'); ?>
							</ul>
                            
                            <div id="comments_pagination">
                                <?php paginate_comments_links(); ?>
                            </div>
						<?php endif; ?>

						<?php
                        endif;
						?>

						<?php
						if(function_exists('comment_form')) :
							comment_form(array(
								'comment_notes_before' => '',
								'comment_notes_after' => '',
								'logged_in_as' => '',
								'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8"></textarea></p>'
							));
						else :
						?>
							<?php if(comments_open()) : ?>
								<div id="respond">
									<h3 id="reply-title"><?php _e('Leave a Reply'); ?> <small><?php cancel_comment_reply_link(); ?></small></h3>
										
									<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
										<?php
										if(get_option('comment_registration') && !$user_ID)
										{
										?>
											<p>
												<?php printf(__('You must be <a href="%1$s/wp-login.php?redirect_to=%2$s">logged in</a> to post a comment.'), get_option('siteurl'), urlencode(get_permalink())); ?>
											</p>
										<?php
										} else {
										?>
											<?php if(!is_user_logged_in()) { ?>
												<p class="comment-form-author">
													<input type="text" name="author" class="data_author" value="<?php _e('Name', 'fazio'); ?>" data-defaultvalue="<?php _e('Name', 'fazio'); ?>">
												</p>
												
												<p class="comment-form-email">
													<input type="text" name="email" class="data_email" value="<?php _e('Email', 'fazio'); ?>" data-defaultvalue="<?php _e('Email', 'fazio'); ?>">
												</p>
												
												<p class="comment-form-url">
													<input type="text" name="url" class="data_url" value="<?php _e('Website', 'fazio'); ?>" data-defaultvalue="<?php _e('Website', 'fazio'); ?>">
												</p>
											<?php } ?>
											<textarea name="comment" id="comment" class="data_comment"></textarea>
											<?php comment_id_fields(); ?>
											<input type="submit" name="submit" class="submit" value="<?php _e('Send comment', 'fazio'); ?>">
										<?php
										}
										?>
									</form>
								</div><!-- end respond -->
							<?php endif; ?>
						<?php endif; ?>

						<?php if(!comments_open() && !is_page()) : ?>

								<p><?php _e('Comments are disabled in this entry.', 'fazio'); ?></p>

						<?php endif; ?>

						<?php if (!empty($comments_by_type['pings'])) : ?>
							<h2>Pingbacks</h2>
							
							<ul class="pings_list">
								<?php wp_list_comments('type=pings&callback=fazio_pings'); ?>
							</ul>
						<?php endif; ?>

				</div><!-- end comments -->